package com.sushi.controller;

import com.sushi.service.UserService;
import com.sushi.response.ResponseBO;
import com.sushi.response.ResponsePageBO;
import com.sushi.response.UserResp;
import com.sushi.request.UserReq;
import com.sushi.request.UserPageReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.*;

/**
 * 用户 控制器
 * @date 2023-05-02
 * @time 17:16:19
 * @author Administrator
 */
@RestController
@Slf4j
public class UserController {

	@Autowired
	private UserService userService;

    

    /**
     * 新增
     */
    @PostMapping("/user/add")
    public ResponseBO<UserResp> add(@RequestBody UserReq req) {
        return userService.add(req);
    }

    /**
     * 逻辑删除
     */
    @PostMapping("/user/remove")
    public ResponseBO<UserResp> remove(@RequestBody UserReq req) {
        return userService.logicRemove(req);
    }

    /**
     * 更新
     */
    @PostMapping("/user/update")
    public ResponseBO<UserResp> update(@RequestBody UserReq req) {
        return userService.updateByField(req);
    }

    /**
     * 列表
     */
    @PostMapping("/user/list")
    public ResponsePageBO<UserResp> list(@RequestBody UserPageReq req) {
        return userService.listByCondition(req);
    }

    /**
     * 详情
     */
    @PostMapping("/user/detail")
    public ResponseBO<UserResp> detail(@RequestBody UserReq req) {
        return userService.detail(req);
    }

    @PostMapping("/signUp")
    public ResponseBO<String> signUp(@RequestBody UserReq req) {
        return userService.signUp(req);
    }

    @PostMapping("/login")
    public ResponseBO<UserResp> login(@RequestBody UserReq req) {
        return userService.login(req);
    }

    @PostMapping("/user/checkAccount")
    public ResponseBO<String> checkAccount(UserReq req) {
        return userService.checkAccount(req);
    }

}